import org.junit.jupiter.api.Test;

import java.lang.reflect.Array;
import java.util.Arrays;

public class _1_两数之和 {
    @Test
    public void test(){
        int[] ints = twoSum(new int[]{2, 7, 11, 15}, 9);
        System.out.println(Arrays.toString(ints));
    }
    public  int[] twoSum(int[] nums, int target) {
        for (int i = 0; i < nums.length; i++) {
            int sum=0;
            for (int j = i+1; j < nums.length; j++) {

                sum=nums[i]+nums[j];
                if (sum==target){
                    return new int[] {i,j};
                }
            }
        }
        return null;
    }
}
